﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using TEST_SCCM_MVC_01.Models;
using System.Web.Configuration;

namespace TEST_SCCM_MVC_01.Models
{
    public class SettingsRepository
    {
        public Settings Get() {

            Settings setting = new Settings();

            setting.AdminMail = WebConfigurationManager.AppSettings["AdminMail"].ToString();
            setting.SCCMUsername = WebConfigurationManager.AppSettings["SCCMUsername"].ToString();
            setting.SCCMPassword = WebConfigurationManager.AppSettings["SCCMPassword"].ToString();
            setting.DeploymentOSRoot = WebConfigurationManager.AppSettings["DeploymentOSRoot"].ToString();
            setting.DeploymentRoomRoot = WebConfigurationManager.AppSettings["DeploymentRoomRoot"].ToString();

            return setting;
        }

        public void Set(Settings Settings)
        {
            try
            {
                WebConfigurationManager.AppSettings["AdminMail"] = Settings.AdminMail;
                WebConfigurationManager.AppSettings["SCCMUsername"] = Settings.SCCMUsername;
                WebConfigurationManager.AppSettings["SCCMPassword"] = Settings.SCCMPassword;
                WebConfigurationManager.AppSettings["DeploymentOSRoot"] = Settings.DeploymentOSRoot;
                WebConfigurationManager.AppSettings["DeploymentRoomRoot"] = Settings.DeploymentRoomRoot;
            }
            catch (System.Configuration.ConfigurationErrorsException ceex)
            {
                throw;
            }
            catch (Exception)
            {
                throw;
            }
        }
    }
}